function getFingerprint() {
    const canvas = document.createElement('canvas');
    const context = canvas.getContext('2d');
    const text = 'Hello, IHarbour';
    context.font = "18pt Arial";
    context.textBaseline = "top";
    context.fillStyle = "#f60";
    context.fillRect(125, 1, 62, 20);
    context.fillStyle = "#069";
    context.fillText(text, 2, 15);
    context.fillStyle = "rgba(102, 204, 0, 0.7)";
    context.fillText(text, 4, 17);

    const b64 = canvas.toDataURL().replace("data:image/png;base64,", "");
    const bin = atob(b64);
    const crc = bin2hex(bin.slice(-16, -12));
    //var crc = bin.slice(-16,-12);
    return crc;
}

function bin2hex(str) {
    let result = "";
    for (let i = 0; i < str.length; i++) {
        result += int16_to_hex(str.charCodeAt(i));
    }
    return result;
}

function int16_to_hex(i) {
    let result = i.toString();
    let j = 0;
    while (j + result.length < 4) {
        result = "0" + result;
        j++;
    }
    return result;
}

export {
    getFingerprint,
}